package com.yuanyi.liu;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class DrawLineTestActivity extends Activity {
	Button button_line;
	Button button_rect;
	Button button_oval;
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        button_line = (Button)findViewById(R.id.button_line);
        button_rect = (Button)findViewById(R.id.button_rect);
        button_oval = (Button)findViewById(R.id.button_oval);
        //自定义直线按钮的响应事件
        OnClickListener listener_line = new OnClickListener(){
			public void onClick(View v) {
				DrawRectView view = new DrawRectView(DrawLineTestActivity.this, 1);
		        setContentView(view);  
		        view.requestFocus();  
			}
        };
        //自定义矩形按钮的响应事件
        OnClickListener listener_rect = new OnClickListener(){
			public void onClick(View v) {
				DrawRectView view = new DrawRectView(DrawLineTestActivity.this, 2);
		        setContentView(view);  
		        view.requestFocus();  
			}
        };
        //自定义椭圆按钮的响应事件
        OnClickListener listener_oval = new OnClickListener(){
			public void onClick(View v) {
				DrawRectView view = new DrawRectView(DrawLineTestActivity.this, 3);
		        setContentView(view);  
		        view.requestFocus();  
			}
        };
        
        button_line.setOnClickListener(listener_line);
        button_rect.setOnClickListener(listener_rect);
        button_oval.setOnClickListener(listener_oval);
    }
    
	//按键事件
	@Override
	public boolean onKeyUp(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
//		switch(keyCode){
//		case KeyEvent.KEY
//		}
		//Log.v("OnKeyUp", String.valueOf(keyCode));
		System.out.println(keyCode);
		return super.onKeyUp(keyCode, event);
	}
    //按键事件
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		Log.v("OnKeyDown", String.valueOf(keyCode));
		System.out.println(keyCode);
		return super.onKeyDown(keyCode, event);
	}
}